C#
When we first make our new GameObject.cs file it should look like this.

After "namespace" will automatically be defaulted to your project name.(It will not be the same as mine)
Here as some explanations of some of the opening statements we are adding.

This states that all of our textures loaded into our game will be sprites. NOTE: Sprite is another word for character or object.

NOTE: public states that whatever is in that call will be used through the entire project, not just that file or void.


This states that everything will have a specific position, location, area, ect. in our game window.


This states that every sprite has the ability to rotate, and or pivot.


This states that every sprite will have a point that is its center. This later on can allow you to do a bunch of things.


This states that every sprite has the ability to have a velocity you can set as its speed.


This states that every sprite can be "alive". This is a very useful feature you can add to make any game more programmer friendly, and just makes everything more accessible and manageable.

Then we need to add this void.

This void states that any Gameobject texture that is loaded will be affected with whats inside this voids Curly Braces{ }.

In this void you should add the following.

Now I will go more in depth about what we just added.


This states that every sprite loaded will have the ability to rotate, but it is loaded it will be defaulted and not rotated.



This states that every loaded sprite will have a position.
Notice that position is set to Vector2.Zero
Vector2 means that everything will be set in a 2d location ((x,y)Horizontal,Vertical), not a 3d location like Vector3((x,y,z)Horizontal,Vertical,Depth).
.None means that this value will be not null but just not defined yet. If it had a value every object would be in the same exact position in the window.
So when we set Vector2 to .None it makes it so later on we can set every sprites position separately later.


This simple and plainly states that every sprite is a loaded texture.



This states that "center" is a 2d point in the window.
(sprite.Width / 2, sprite.Height / 2) states where this point is.
Notice it is half of a sprites width, and half of a sprites height, this obviously would be the center point.
Also notice its (width,height) which also could be known as a (x,y) coordinate point.
This has to be in parenthesis ( ) because this is proper way to format a point and it allows it to call back to the Vector2 call.



This simply states that any sprite is allowed to have a velocity.
Like before you notice this is set to Vector2 so all sprites can only move along the (x,y) axises.
It also like before is set to .None so you can set it so different sprites have different velocities, so you set it to .None so you can input that integer in later.


This states that every sprite is not "alive" so every GameObject is dead. Doing this is very useful.
Ex. If you have a game with different levels you don't want everything alive as soon as you start the game.
You can simply make a sprite alive by adding "sprite.alive = true" in your game code at the point when you want a sprite to be called and become "alive".


Final Result





Download My Source Code Here with RapidShare.
Download
Free Web Hosting